/*
 * Moviment.h
 *
 *  Created on: 06/02/2013
 *      Author: eusyar
 */

#ifndef MOVIMENT_H_
#define MOVIMENT_H_

#include "core/GameComponent.h"
#include "Animation.h"
#include "util/Helpers.h"
#include <vector>
#include <iostream>

using namespace std;
using namespace eats_vars;

namespace eats_core {

class Route {

public:

	Route(){
		actual_pos = 0;
	}

	Route(vector<Point> _points_route) {
		actual_pos = 0;
		points_route = _points_route;
	}

	bool switchToNextPosition(){
		if((actual_pos+2) > points_route.size() ){
			return false;
		} else {
			actual_pos++;
			return true;
		}
	}

	Point getTargetPosition(){
		return points_route.at(actual_pos);
	}

	Point getFinalPosition(){
		return points_route.at(points_route.size()-1);
	}

private:

	vector<Point> points_route;
	int actual_pos;


};

class Moviment : public GameComponent{

public:

	Moviment(vector<Point> points_route, int speed, int * posX, int * posY);
	Moviment(int * posX, int * posY);
	virtual ~Moviment();

	bool update();
	bool setUp();
	bool tearDown();

	void setRoute(vector<Point> points_route){
		if(_route != NULL){
			delete _route;
		}
		_route = new Route(points_route);
	};

	void setSpeed(int speed){
		_speed = speed;
	};

	Route getRoute(){
		return *_route;
	};

	int getSpeed(){
		return _speed;
	};

	Point getFinalPosition() {
		return _route->getFinalPosition();
	}


protected:

	Route * _route;
	int _speed;

	bool _stopChecking;

	vector<Point> _points_route;

	int * _posX,  * _posY;

};

}

#endif /* MOVIMENT_H_ */
